package cn.edu.scau.cmi.zenglinghong.Singleton;

import java.util.Map;
import java.util.HashMap;

public class Marshal {
	private String name;
	public static int maxNumber = 10;
	private static Map<String,Marshal> marshalsMap = new HashMap<String,Marshal> (maxNumber);
	private Marshal(String name) {
		this.name = name;
	}
	public static Marshal getInstance(String name) {
		if(marshalsMap.containsKey(name)) return marshalsMap.get(name);
		Marshal instance = null;
		if(marshalsMap.size()<maxNumber) {
			instance = new Marshal(name);
			marshalsMap.put(name, instance);
		}
		return instance;
	}
	public String getName() {
		return name;
	}
	public static int getSize() {
		return marshalsMap.size();
	}
}
